/*----------------------------------------------------------------------------
 * osObjects.h: CMSIS-RTOS global object definitions for an application
 *----------------------------------------------------------------------------
 *
 * This header file defines global RTOS objects used throughout a project
 *
 * #define osObjectsPublic indicates that objects are defined; without that
 * definition the objects are defined as external symbols.
 *
 *--------------------------------------------------------------------------*/


#ifndef __osObjects
#define __osObjects


#ifdef osObjectsCreat
#define OBJ_EXT  
#else
#define OBJ_EXT extern 
#endif

#include "cmsis_rt.h"

#define ms_ticks(x)        (x*RT_TICK_PER_SECOND/1000)

// init--------------------- ---------------------------------------------------
void rt_hw_tick_init(void);
int Init_Thread (void);

// global 'thread' functions ---------------------------------------------------
#define  STK_SIZE(x)                             (x*4)

OBJ_EXT rt_thread_t  tid_GuiTask;                                  // thread id
OBJ_EXT rt_thread_t  tid_LedTask;                                  // thread id
OBJ_EXT rt_thread_t  tid_mjTask;                                   // thread id
OBJ_EXT rt_thread_t  tid_flashTask;                                // thread id
OBJ_EXT rt_thread_t  tid_mbTask;                                   // thread id
OBJ_EXT rt_thread_t  tid_daemon; 
OBJ_EXT rt_thread_t  tid_o3sim; 
OBJ_EXT rt_thread_t  tid_o3ctr; 
OBJ_EXT rt_thread_t  tid_touch; 
OBJ_EXT rt_thread_t  tid_q25; 
OBJ_EXT rt_thread_t  tid_nandtask;

#define  TASK_TASK_SW_TEST_STK_SIZE              STK_SIZE(0x200)
#define  TASK_TASK_SW_TEST_PRIO                  OS_PRIO_LOW
OBJ_EXT  void           SwTestTask               (void  *p_arg);
OBJ_EXT rt_thread_t  tid_SwTestTask;

#define  TEST_TASK_STK_SIZE                      STK_SIZE(0x400)
#define  TEST_TASK_PRIO                          OS_PRIO_LOW
OBJ_EXT  void TestTask(void *p_arg);
OBJ_EXT rt_thread_t  tid_TestTask;

// global 'semaphores' ---------------------------------------------------------

OBJ_EXT rt_sem_t   sid_led;

OBJ_EXT rt_mutex_t mid_sdcard;
OBJ_EXT rt_mutex_t mid_iichal;
OBJ_EXT rt_mutex_t mid_malloc;
OBJ_EXT rt_mutex_t mid_spiflash;

OBJ_EXT rt_mutex_t mid_q25;

OBJ_EXT rt_sem_t sid_mbx;

OBJ_EXT rt_sem_t sid_SwTest;

// global 'message queues' -----------------------------------------------------
OBJ_EXT rt_mq_t  qid_mbx;

OBJ_EXT rt_mq_t  qid_mj;
#define Q_MJ_SIZE   (sizeof(uint32_t))

OBJ_EXT rt_mailbox_t qbid_gui;
OBJ_EXT rt_mailbox_t qbid_flash;

// global event
OBJ_EXT rt_event_t eid_mbx;

// global 'mail queues' ----------------------------------------------------------


#endif  // __osObjects
